﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using CellarDoor.Gui;
using CellarDoor.Gui.Elements;
using CellarDoor.Gui.Animation;


namespace CellarDoor.Gui.Demo.DemoScreens
{
    public class ElementsScreen : BaseScreen
    {
        public ElementsScreen(UiManager manager)
            : base(manager)
        {
            Initialize();
        }

        private void Initialize()
        {
            //
            // Check boxes
            //
            var check = new UiCheckBox(Panel);
            check.Top = 10;
            check.Left = 10;
            check.Text = "Check 1";

            check = new UiCheckBox(Panel);
            check.Top = 45;
            check.Left = 10;
            check.Text = "Check 2";

            check = new UiCheckBox(Panel);
            check.Top = 80;
            check.Left = 10;
            check.Text = "Check 3";

            //
            // Radio groups
            //
            CreateRadioGroup(1, Panel, new Point(130, 10));

            var groupPanel = new UiPanel(Panel);
            groupPanel.Top = 10;
            groupPanel.Left = 260;
            groupPanel.Width = 150;
            groupPanel.Height = 120;
            CreateRadioGroup(1, groupPanel, new Point(10, 10));

            //
            // Dragable Panel
            //
            var dragablePanel = new UiPanel(Panel);
            dragablePanel.Width = 100;
            dragablePanel.Height = 100;
            dragablePanel.Text = "Dragable";
            dragablePanel.Dragable = true;
            dragablePanel.Top = 10;
            dragablePanel.Left = 430;

            //
            // Progress bar
            //
            var progress = new UiProgressBar(Panel);
            progress.Width = 200;
            progress.Height = 30;
            progress.Top = 120;
            progress.Left = 10;

            var slideX = new UiSlideBar(Panel);
            slideX.BarStyle = UiOrientation.Horizontal;
            slideX.Width = 200;
            slideX.Height = 30;
            slideX.Top = 160;
            slideX.Left = 10;
            slideX.ValueChanged += (s, e) =>
            {
                progress.Value = slideX.NormalizedValue;
            };

            var scrollBar = new UiScrollBar(Panel);
            scrollBar.BarStyle = UiOrientation.Horizontal;
            scrollBar.Width = 200;
            scrollBar.Height = 25;
            scrollBar.Top = 190;
            scrollBar.Left = 10;

        }

        private void CreateRadioGroup(int index, UiElement parent, Point offset)
        {
            var radio = new UiRadioButton(parent);
            radio.Top = offset.Y;
            radio.Left = offset.X;
            radio.Text = "Radio 1";

            radio = new UiRadioButton(parent);
            radio.Top = 35 + offset.Y;
            radio.Left = offset.X;
            radio.Text = "Radio 2";

            radio = new UiRadioButton(parent);
            radio.Top = 70 + offset.Y;
            radio.Left = offset.X;
            radio.Text = "Radio 3";
        }
    }
}
